//
//  BLEManager.h
//  KiWiPeniOSProject
//
//  Created by 曾威林 on 2017/8/27.
//  Copyright © 2017年 zjy. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>


typedef enum : NSUInteger {
    SearchTypeAll,      //搜索所有的设备
    SearchTypeSaved,    //搜索保存过的设备
    SearchTypeUnsaved,  //搜索没有保存过的设备
} SearchType;


typedef void(^BLESearchBlock)(BOOL success, NSArray<CBPeripheral *> *peripheralList);//搜索相关的
typedef void(^BLEConnectBlock)(BOOL success);//连接相关处理
typedef void(^BLEReceiveDataBlock)(NSData *messageData);//处理接收到消息

//内部已经做了数据超过20个字节时候拼接的问题
@interface BLEManager : NSObject

+ (instancetype)shareBLEManager;

- (NSString *) getConnectingPeripheralUUID;
- (void)getMatchedPeripheralsWithSearchBlock:(BLESearchBlock)bleSearchBlock;//获取已经配对过的设备
- (void)scanPeripheralsWithSearchType:(SearchType) searchType SearchBlock:(BLESearchBlock)bleSearchBlock;
- (void)connectWithPeripheral:(CBPeripheral *)peripheral AndConnectBlock:(BLEConnectBlock)bleConnectBlock;//连接设备
- (void)writeDataWithData:(NSData *)data;//发送数据给蓝牙

- (void)readData;//主动从蓝牙设备读取数据
- (void)cancelAll;//取消扫描，断开连接




@end
